/*
 * @Description: 线程状态
 * @Author: rendc
 * @Date: 2025-08-19 14:26:24
 * @LastEditors: rendc
 * @LastEditTime: 2025-08-19 14:56:30
 */
public class Test05State {
  public static void main(String[] args) throws Exception {
    Thread t1 = new Thread("t1子线程") {
      @Override
      public void run() {
        for (int i = 0; i < 6; i++) {
          try {
            if (i == 3) {
              Thread.sleep(500);
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
          System.out.println("t1子线程-i:" + i);
        }
      }
    };
    // 获取线程状态 NEW
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    t1.start();
    // 获取线程状态 Runable
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    // 主线程休眠
    Thread.sleep(500);
    // 获取线程状态 ？
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    System.out.println(t1.getState());
    // 主线程休眠
    Thread.sleep(500);
    // 获取线程状态 ？
    System.out.println(t1.getState());
    System.out.println(t1.getState());
  }
}